package com.gang.service;

import com.gang.controller.HelloController;
import com.gang.dao.User;
import com.gang.dao.UserService;
import java.io.Serializable;
import java.util.concurrent.ThreadPoolExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**配合ActiveMqConfigsyn使用
 * @author: 李刚
 * @time: 2020/5/3 12:17
 * @description: 从队列中获取数据
 */
@Component
public class Consumer {

    @Autowired
    private UserService userService;


    @JmsListener(destination = "MyQueue", containerFactory = "jmsListenerContainerQueue")
    public void receive(String msg) {
      System.out.println(Thread.currentThread().getId());
      System.out.println("MyQueue收到msg:" + msg);
    }

    @JmsListener(destination = "MyQueue", containerFactory = "jmsListenerContainerQueue")
    public void receiveFromQueue(String msg) {
      System.out.println(Thread.currentThread().getId());
      System.out.println("MyQueue收到msg:" + msg);
    }

   @JmsListener(destination = "MyTopic", containerFactory = "jmsListenerContainerTopic")
   public void receive1(String msg) {
     System.out.println(Thread.currentThread().getId());
     System.out.println("MyTopic收到msg:" + msg);
    }
}
